package com.hspedu.enum_;

/**
 * @Author Stringzhua
 * @Date 2024/3/6 20:29
 * description:
 */
public class Enumeration02 {
    public static void main(String[] args) {
        System.out.println(Season.SPRING);
        System.out.println(Season.SUMMER);
        System.out.println(Season.AUTUMN);
        System.out.println(Season.WINTER);
    }
}
//1.自定义类实现枚举
class Season {//类
    private String name;//季节
    private String desc;//描述
    //3.定义了四个对象
    public static final Season SPRING =new Season("春天", "温暖");
    public static final Season WINTER =new Season("冬天", "寒冷");
    public static final Season AUTUMN =new Season("秋天", "凉爽");
    public static final Season SUMMER =new Season("夏天", "炎热");

    //1.将构造器私有化,目的是防止直接被new
    //2.去掉setXxx相关的方法,目的是防止属性被修改
    //3.在Season内直接创建固定的对象
    //4.优化,可以再加入一个final修饰符
    private Season(String name, String desc) {
        this.name = name;
        this.desc = desc;
    }

    public String getName() {
        return name;
    }

//    public void setName(String name) {
//        this.name = name;
//    }

    public String getDesc() {
        return desc;
    }

//    public void setDesc(String desc) {
//        this.desc = desc;
//    }

    @Override
    public String toString() {
        return "Season{" +
                "name='" + name + '\'' +
                ", desc='" + desc + '\'' +
                '}';
    }
}